Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] feat: Specification을 Querydsl로 대체한다 (#604) #609

Merged
merged 11 commits into from
Nov 19, 2023
Merged

Conversation

BGuga
Copy link
Member

@BGuga BGuga commented Nov 14, 2023

📌 관련 이슈

✨ PR 세부 내용

Specification 로직을 Querydsl로 변경했습니다
참고 자료 :
향로 Querydsl CustomRepository 를 중심으로
Querydsl 기본 사용법
SpringBoot 3.x 이상 gradle 설정

@BGuga BGuga linked an issue Nov 14, 2023 that may be closed by this pull request
@BGuga BGuga self-assigned this Nov 14, 2023
Copy link

github-actions bot commented Nov 14, 2023

Unit Test Results

  89 files    89 suites   10s ⏱️
318 tests 318 ✔️ 0 💤 0
332 runs  332 ✔️ 0 💤 0

Results for commit 59752a5.

♻️ This comment has been updated with latest results.

@BGuga BGuga added BE 백엔드에 관련된 작업 ⚙️ 리팩터링 리팩터링에 관련된 작업 labels Nov 14, 2023
Copy link
Collaborator

@seokjin8678 seokjin8678 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 남겼습니다!
쿼리DSL 적용하니 확실히 깔끔하네요

Comment on lines 10 to 15
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 설정 롬복 때문에 필요했던 것 같은데, QueryDSL 적용에도 필요한가요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해제 했을 때 빌드 되는지 확인 필요할 것 같네요.
intelliJ, gradle 두 개 다요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삭제했고 둘 다 빌드 되는 것 확인했습니다.

@@ -67,7 +67,8 @@ public enum ErrorCode {
INVALID_ROLE_NAME("해당하는 Role이 없습니다."),
FOR_TEST_ERROR("테스트용 에러입니다."),
FAIL_SEND_FCM_MESSAGE("FCM Message 전송에 실패했습니다."),
FCM_NOT_FOUND("유효하지 않은 MemberFCM 이 감지 되었습니다.");
FCM_NOT_FOUND("유효하지 않은 MemberFCM 이 감지 되었습니다."),
NOT_DEFINED_FESTIVAL_FESTIVAL("정의되지 않은 축제 필터입니다.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT_DEFINED_FESTIVAL_FESTIVAL
아는 형님의 아는 형님의

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않게 되어 삭제했습니다.

import java.time.LocalDate;
import java.util.List;

public interface FestivalRepositoryCustom {
Copy link
Collaborator

@seokjin8678 seokjin8678 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.single-repository-behavior
스프링 문서에는 접두사에 Custom을 사용하는데, 접미사로 Custom을 사용해주신 이유가 따로 있나요?

case PLANNED -> plannedFestivals(currentTime);
case PROGRESS -> progressFestivals(currentTime);
case END -> endFestivals(currentTime);
default -> throw new InternalServerException(ErrorCode.NOT_DEFINED_FESTIVAL_FESTIVAL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch에 Enum을 사용한다면, Default는 굳이 명시해주실 필요가 없습니다..!
왜냐하면 컴파일러가 어떠한 Enum이 있는지 알고 있기 때문이죠!!!
TMI로 해당 사항은 sealed 키워드를 구현한 클래스들도 포함이 됩니다. 아마 자바 17에선 안되고 그 이상에서는 되는걸로 기억하네요

private final JPAQueryFactory queryFactory;

@Override
public List<Festival> findFestivalBy(FestivalFilter festivalFilter, LocalDate currentTime) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findByFilter 라는 이름은 어떠신가요?
또한, Clock을 의존하게 해서, LocalDate.now(clock)을 내부에서 사용하게 한다면 인자로 들어오는 currentTime은 필요 없을 것 같은데 이 부분은 테스트 용이성을 위해 열어두신건가요?

Copy link
Member Author

@BGuga BGuga Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네네 맞아용

Comment on lines 23 to 24
@SpringBootTest(webEnvironment = WebEnvironment.NONE)
@Transactional
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@SpringBootTest(webEnvironment = WebEnvironment.NONE)
@Transactional
@RepositoryTest

BGuga and others added 3 commits November 16, 2023 14:54
# Conflicts:
#	backend/src/test/java/com/festago/stage/repository/StageRepositoryTest.java
@seokjin8678
Copy link
Collaborator

충돌 해결했습니당

Copy link
Collaborator

@seokjin8678 seokjin8678 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 반영 확인했습니다!

Copy link
Collaborator

@carsago carsago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

멋진 성장입니다 푸우.

Copy link
Member

@xxeol2 xxeol2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Querydsl 멋있네요 👍

@seokjin8678 seokjin8678 merged commit 9395c25 into dev Nov 19, 2023
3 checks passed
@seokjin8678 seokjin8678 deleted the feat/#604 branch November 19, 2023 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드에 관련된 작업 ⚙️ 리팩터링 리팩터링에 관련된 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] Specification 을 Querydsl 로 변경한다.
4 participants